(function(w){
    var post = function () {
        this.Init();
        return this;
    }, params={},c = {},iscroll = {},reqControl = true,ts = "",
        singleClassList = false,userId = "",communityId="",
        thisClass = "question",reported= 0, level = 0, acrossCity = 0, noreply = 0, noadopt = 0, noreply_t = 0,qString = "",canRefresh = false,dHtml = "",searchPage = 1,
        isActivityList = false;//活动列表
        thumbnail="?imageView2/1/w/200/h/200/q/75/format/jpg" //--缩略图
        headimg="?imageView2/1/w/80/h/80/q/75/format/jpg" //--头像
    post.prototype = {

        Init: function () {



            c = this;

            userId = getQueryString('userId');
            params.type =  getQueryString('type');
            params.vcode = getQueryString('vcode');
            if(params.type === "ios")
            {
                $('header').css("top",9);
                $('.select-title').css('padding-top',9);
            }
            this.data = {"url":"/rest/v1.0/backoffice/Systems/getSystemConfig"};
            netWork(this.data,this.getResUrl);




            $("#section_list")[0].style.height = (document.body.offsetHeight - $("#section_list")[0].offsetTop) +"px";
            iscroll = new iScroll("section_list", { "useTransition": true, "vScrollbar": false, "hScroll": false, "onScrollStart": function () {
            }, "onScrollMove": function () {
                if(Math.abs(this.maxScrollY) - Math.abs(this.y) < -40 || this.maxScrollY >= 0){
                    if(reqControl){
                        $("#scroll_tip").text("松手刷新");
                        canRefresh = true;
                    }
                }
            }, "onScrollEnd": function () {
                if(reqControl && canRefresh){
                    reqControl = false;
                    canRefresh = false;
                    if(ts != ""){
                       /*alert("ts!="+communityId);*/
                        <!--  宝宝树66小区二次改造    mod   chenf  20170807   start   -->
                        /*c.data = {"url":"/rest/v1.0/Questions/getAllCommunityQuestionListNew/"+ts+"/"+userId+"/0/0"+"/opm4mobile","loading": c.listload,"endLoading": c.removeloading};*/
                        c.data = {"url":"/rest/v1.0/Questions/getAllCommunityQuestionListNew/"+ts+"/"+userId+"/1/"+communityId+"/opm4mobile","loading": c.listload,"endLoading": c.removeloading};
                        <!--  宝宝树66小区二次改造    mod   chenf  20170807   start   -->
                        if(singleClassList == true){
                            <!--  宝宝树66小区二次改造    mod   chenf  20170807   start   -->
                            /*c.data.url = "/rest/v1.0/Questions/getCategoryQuestionListNew/"+thisClass+"/"+ts+"/"+userId+"/0/0"+"/opm4mobile";*/
                            c.data.url = "/rest/v1.0/Questions/getCategoryQuestionListNew/"+thisClass+"/"+ts+"/"+userId+"/1/"+communityId+"/opm4mobile";
                            <!--  宝宝树66小区二次改造    mod   chenf  20170807   end   -->
                        }
                        c.data.url += qString;
                    }else{
                       /*alert("ts=="+communityId);*/
                        <!--  宝宝树66小区二次改造    mod   chenf  20170807   start   -->
                        /*c.data.url = "/rest/v1.0/Systems/searchAppUgcNew/"+searchPage+"/"+userId+"/0/0"+"/deviceId";*/
                        c.data.url = "/rest/v1.0/Systems/searchAppUgcNew/"+searchPage+"/"+userId+"/1/"+communityId+"/deviceId";
                        <!--  宝宝树66小区二次改造    mod   chenf  20170807   end   -->
                        searchPage++;
                    }
                    console.log(ts);
                    netWork(c.data,c.listHandle);
                }
            }});




            <!--  宝宝树66小区二次改造    add   gct  20170807   start   -->

            $.ajax({
                type: 'get',
                <!--  宝宝树66小区二次改造    mod   guo.xiaomin  20170815   start   -->
                // 版主管理，帖子管理，当前小区下拉框
                // url: "http://172.16.97.250:3008/rest/v1.0/Questions/getCommunityByUserID/"+userId, // 旧
                url: "/rest/v1.0/Questions/getCommunityByUserID/" + userId, // 新
                <!--  宝宝树66小区二次改造    mod   guo.xiaomin  20170815   end   -->

                data: {},
                dataType:"json",
                success: function(data)
                {
                    for(var i=0;i<data.data.length;i++) {
                        //  alert(data.data[i].communityName);
                        communityId=data.data[i].objId;
                        var a="<li class = 'selected'  data-val='"+data.data[i].objId+"'>"+data.data[i].communityName+"</li>";
                        $("#select_Community_ul").html(a);
                        $("#community").html(data.data[i].communityName);

                    }
                    var flag=true;
                    if(flag)
                    {
                       // flag=false;
                        $.ajax({
                            type: 'get',
                            <!--  宝宝树66小区二次改造    mod   guo.xiaomin  20170815   start   -->
                            // url: "http://172.16.97.250:3008/rest/v1.0/Questions/getCommunityAll/"+userId, // 旧
                            url: "/rest/v1.0/Questions/getCommunityAll/"+userId, // 新
                            <!--  宝宝树66小区二次改造    mod   guo.xiaomin  20170815   end   -->

                            data: {},
                            dataType:"json",
                            success: function(data)
                            {


                                for(var i=0;i<data.data.length;i++) {
                                    //  alert(data.data[i].communityName);
                                    var a="<li  data-val='"+data.data[i].objId+"'>"+data.data[i].communityName+"</li>";
                                    if(i==0)
                                    {
                                        $("#select_Community_ul").append(a);
                                    }
                                    else
                                    {
                                        $("#select_Community_ul").append(a);
                                    }
                                }

                                $("#select_Community_ul li").on("click",function(){
                                    communityId=this.dataset.val;
                                    /*alert($(this).text());*/
                                    $(this).siblings().removeClass("selected");
                                    $(this).addClass("selected");

                                    $("#community").text($(this).text());
                                    $("#community").removeClass("selected");
                                    $("#select_Community").css("display","none");
                                    $("#mask").css("display","none");
                                    $(".community img").attr("src","../../images/arrow_down.png");

                                    if(c.data.method)delete c.data.method;

                                    singleClassList = true;
                                    $("#post_list").html("");
                                    var classifyValue=$("#classify").text();
                                  /*  alert(classifyValue);*/
                                    if("全部"==classifyValue)
                                    {
                                        singleClassList = false;
                                        $("#post_list").html("");

                                        c.data.url = "/rest/v1.0/Questions/getAllCommunityQuestionListNew/0/"+userId+"/1/"+communityId+"/opm4mobile"+qString;
                                        netWork(c.data,c.listHandle);
                                        c.itemClass = false;
                                    }
                                       // $("#GctAll").click();

                                     else if(classifyValue=="邻里问问")
                                    {
                                       /* alert("邻里："+classifyValue);*/
                                       // $("#GctQuestion").click();
                                        c.data.url = "/rest/v1.0/Questions/getCategoryQuestionListNew/question/0/"+userId+"/1/"+communityId+"/opm4mobile"+qString;

                                        singleClassList = true;
                                        $("#post_list").html("");

                                        isActivityList = false;

                                        netWork(c.data,c.listHandle);
                                        thisClass = this.dataset.val;
                                        c.dUrl = c.data.url;
                                        c.itemClass = true;
                                    }
                                     else if(classifyValue=="随便说说")
                                    {
                                       /* alert("随便："+classifyValue);*/
                                       // $("#GctTalk").click();
                                        c.data.url = "/rest/v1.0/Questions/getCategoryQuestionListNew/share/0/"+userId+"/1/"+communityId+"/opm4mobile"+qString;
                                        singleClassList = true;
                                        $("#post_list").html("");

                                        isActivityList = false;

                                        netWork(c.data,c.listHandle);
                                        thisClass = this.dataset.val;
                                        c.dUrl = c.data.url;
                                        c.itemClass = true;
                                    }
                                    isActivityList = false;

                                   /* netWork(c.data,c.listHandle);
                                    thisClass = this.dataset.val;
                                    c.dUrl = c.data.url;
                                    c.itemClass = true;*/

                                });

                            }

                        });
                    }
                }

            });

            <!--  宝宝树66小区二次改造    add   gct  20170807   end   -->

            //alert("oo:"+communityId);
            this.data = {"url":"/rest/v1.0/Questions/getAllCommunityQuestionListNew/0/"+userId+"/0/0"+"/opm4mobile","loading": c.listload,"endLoading": c.removeloading};
            netWork(this.data,this.listHandle);
            dHtml = $("#post_details").html();
            this.dUrl = this.data.url;
        },
        getResUrl: function(data){
            var d = eval("("+data+")");
            if(d.result.status == "1") sessionStorage.resUrl = 'http://'+ d.data.resUrl;
            $("#submit").trigger("trigger2");
        },
        listHandle: function(data){
            var d = eval( "(" + data + ")"),html = "",date,imagesList = "",tagList = "",listContent = "",lastTime;

            if(singleClassList == true){
                if(d.data.activityList){
                    d.data.all = d.data.activityList;
                }else if(d.data.categoryList){
                    d.data.all = d.data.categoryList;
                }
            }
            if(d.data.ugcList){
                d.data.all = d.data.ugcList;
            }

            if(d.data.all.length == 0){
                document.getElementById("post_list").innerHTML += "<li id = 'scroll_tip' style = 'padding: 12px 0;font-size: 14px; color: #ccc;text-align: center;'>没有更多数据了</li>";
                iscroll.refresh();
                setTimeout(function(){
                    iscroll.scrollTo(0, iscroll.maxScrollY, 100);
                });
                return;
            }
            d.data.all.forEach(function(item){
                date = new Date(item.dateCreated);
                lastTime = new Date(item.deadline);
                imagesList = "";
                if(item.images){
                    for(var i = 0;i < item.images.length;i++){
                        var url = sessionStorage.resUrl+item.images[i].imageURL;
                        var imgIndex = url.lastIndexOf(".");
                        url = url.substring(0,imgIndex)+url.substring(imgIndex);
                        imagesList += "<div style = 'background: url("+ url +thumbnail+") no-repeat center;background-size: 100% auto;'></div>";
                    }
                }
                if(item.tag){
                    for(var i = 0;i < item.tag.length;i++){
                        if(typeof item.tag[i] == 'object'){
                            tagList += "<span>"+item.tag[i].value+"</span>";
                        }else{
                            tagList += "<span>"+item.tag[i]+"</span>";
                        }
                    }
                }
                if(!d.data.ugcList){
                    listContent = item.desc.length > 30?item.desc.substring(0,30)+"...":item.desc;
                }else{
                    listContent = item.desc;
                }
                var createImg = sessionStorage.resUrl+'/images/F6DA12FC-D0FC-4254-BE81-4AA25B67682B.webp';
                if(item.createdBy.images && item.createdBy.images.length>0){
                    createImg = sessionStorage.resUrl+item.createdBy.images[0].imageURL;
                }
                //每个用户发的贴子html拼接
                html += "<li data-obj-Id = '"+ item.objId +"' id = '"+ item.objId +"' data-category = '"+item.category+"'><div class = 'title'><img src = '"+createImg+headimg+"' onerror = 'imgLoadError(this)'><span "+(item.category == "neighbourActivity"?"style = 'width: 40%;'":"")+"><span class = 't-name ell'>"+item.createdBy.nickName+"</span><br><span class = 't-time ell'>"+ formatTime(date) +"</span></span>"+(item.category == "neighbourActivity"?("<span class = 'l-time'><span>结束时间：</span><br><span>"+ formatTime(lastTime) +"</span></span>"):"")+(item.isPrime?"<img src = '/pages/moderatorManager/images/jing.png' class = 'jing'>":"")+ (false?"<img src = '/pages/moderatorManager/images/ding.png' class = 'ding'>":"") +"</div><div class = 'clear'></div><div class = 'content'>"+ listContent +"</div> <div class = 'img-area'>"+imagesList+"</div><div class = 'footer'><span class = 'attribute'>"+tagList+"</span><span class = 'browse'><span>"+(isNaN(item.browserCountStr)?0:item.browserCountStr)+"</span><span>"+item.replyCountStr+"</span><span>"+(item.praiseCount?item.praiseCount:0)+"</span></span></div><div class = 'clear'></div><div style = 'width: 100%;height: 8px;background: #EEEBEB;margin-top: 10px;'></div></li>";
                tagList = "";
            });

            $("#post_list").append(html);
            if(d.data.ts) ts = d.data.ts; else ts = "";
            console.log(ts);
            reqControl = true;
            $("#post_list").append("<li id = 'scroll_tip' style = 'padding: 12px 0;font-size: 14px; color: #ccc;text-align: center;'>上拉加载更多</li>");
            iscroll.refresh();

        },
        listload: function(){
            iscroll.refresh();
            $("#scroll_tip").text("正在加载中...");
        },
        removeloading: function(){
            if(document.getElementById("scroll_tip"))document.getElementById("post_list").removeChild(document.getElementById("scroll_tip"));
            iscroll.refresh();
        },
        //事件绑定初始化
        evt: function(){
            $("#back").on("click",function(){
                //location.href = "/pages/moderatorManager/html/index.html";
                window.location='moderator_back.html';
                //tip.toast("now is clicked");
                try {
                    javascript:webviewhandle.finish();
                }catch (exception)
                {
                    console.log('返回了不');
                }
            });

            $(".classify").on("click",function(){
                if(new RegExp("arrow_up.png").test($(".classify img")[0].src)){
                    $(".classify img").attr("src","../../images/arrow_down.png");
                    $("#classify").removeClass("selected");
                    $("#mask").css("display","none");
                    $("#select_list").css("display","none");
                    return;
                }
                $("#filter").removeClass("selected");
                $("#classify")[0].className = "selected";
                $("#select_list").css("display","block");
                $("#filter_list").css("display","none");
                $("#mask").css("display","block");
                $(".classify img").attr("src","../../images/arrow_up.png");
                $(".filter img").attr("src","../../images/arrow_down.png");
                <!--  宝宝树66小区二次改造    add   gct  20170804   start   -->
                $("#select_Community").css("display","none");
                $("#community").removeClass("selected");
                $(".community img").attr("src", "../../images/arrow_down.png");
                <!--  宝宝树66小区二次改造    add   gct  20170804   end   -->
            });

            /*  宝宝树66小区二次改造    add   gct  20170804   start   */





            /*  宝宝树66小区二次改造    add   gct  20170804   end   */

            /*宝宝树66小区二次改造    add   gct  20170807   start */


            /*宝宝树66小区二次改造    add   gct  20170807   end*/

            // 点击分类
            $("#select_list li").on("click",function(){

                $(this).siblings().removeClass("selected");
                $(this).addClass("selected");
                $("#classify").text($(this).text());
                $("#classify").removeClass("selected");
                $("#select_list").css("display","none");
                $("#mask").css("display","none");
                $(".classify img").attr("src","../../images/arrow_down.png");

                if(c.data.method)delete c.data.method;
                if(this.dataset.val == ""){//全部

/*alert("全部:"+communityId);*/
                    singleClassList = false;
                    $("#post_list").html("");
                    c.data.url = "/rest/v1.0/Questions/getAllCommunityQuestionListNew/0/"+userId+"/1/"+communityId+"/opm4mobile"+qString;
                    netWork(c.data,c.listHandle);
                    c.itemClass = false;
                }else{//其他选项
                 /*  alert(communityId);*/
                    singleClassList = true;
                    $("#post_list").html("");

                    c.data.url = "/rest/v1.0/Questions/getCategoryQuestionListNew/"+this.dataset.val+"/0/"+userId+"/1/"+communityId+"/opm4mobile"+qString;
                    isActivityList = false;

                    netWork(c.data,c.listHandle);
                    thisClass = this.dataset.val;
                    c.dUrl = c.data.url;
                    c.itemClass = true;
                }
            });

            $(".filter").on("click",function(){
                if(new RegExp("arrow_up.png").test($(".filter img")[0].src)){
                    $(".filter img").attr("src","../../images/arrow_down.png");
                    $("#filter").removeClass("selected");
                    $("#mask").css("display","none");
                    $("#filter_list").css("display","none");
                    return;
                }
                <!--  宝宝树66小区二次改造    mod   gct  20170804   start   -->
                    $("#classify").removeClass("selected");
                    $("#filter")[0].className = "selected";
                    $("#select_list").css("display", "none");
                    $("#filter_list").css("display", "block");
                    $("#mask").css("display", "block");
                    $(".classify img").attr("src", "../../images/arrow_down.png");
                    $(".filter img").attr("src", "../../images/arrow_up.png");
                    <!--  宝宝树66小区二次改造    add   gct  20170804   start   -->
                    $("#select_Community").css("display","none");
                    $("#community").removeClass("selected");
                    $(".community img").attr("src", "../../images/arrow_down.png");
                    <!--  宝宝树66小区二次改造    add   gct  20170804   end   -->

                <!--  宝宝树66小区二次改造    mod   gct  20170804   end   -->
            });

          /*  $(".classify").on("click",function(){
                if(new RegExp("arrow_up.png").test($(".classify img")[0].src)){
                    $(".classify img").attr("src","../../images/arrow_down.png");
                    $("#classify").removeClass("selected");
                    $("#mask").css("display","none");
                    $("#select_list").css("display","none");
                    return;
                }
                <!--  宝宝树66小区二次改造    add   gct  20170804   start   -->
                $("#filter").removeClass("selected");
                $("#classify")[0].className = "selected";
                $("#select_list").css("display", "block");
                $("#filter_list").css("display", "none");
                $("#mask").css("display", "block");
                $(".classify img").attr("src", "../../images/arrow_up.png");
                $(".filter img").attr("src", "../../images/arrow_down.png");
                <!--  宝宝树66小区二次改造    add   gct  20170804   start   -->
                $("#select_Community").css("display","none");
                $("#community").removeClass("selected");
                $(".community img").attr("src", "../../images/arrow_down.png");


                <!--  宝宝树66小区二次改造    add   gct  20170804   end   -->

            });*/


            $(".community").on("click",function(){
                if(new RegExp("arrow_up.png").test($(".community img")[0].src)){
                    $(".community img").attr("src","../../images/arrow_down.png");
                    $("#community").removeClass("selected");
                    $("#mask").css("display","none");
                    $("#select_Community").css("display","none");
                    return;
                }

                <!--  宝宝树66小区二次改造    add   gct  20170804   start   -->

                    $("#classify").removeClass("selected");
                    $("#filter").removeClass("selected");
                    $("#select_list").css("display", "none");
                    $("#filter_list").css("display", "none");
                    $("#mask").css("display", "block");
                    $(".classify img").attr("src", "../../images/arrow_down.png");
                    $(".filter img").attr("src", "../../images/arrow_down.png");
                    $(".community img").attr("src", "../../images/arrow_up.png");
                    $("#select_Community").css("display", "block");
                   $("#community")[0].className = "selected";


                <!--  宝宝树66小区二次改造    add   gct  20170804   end   -->



            });


            function removeAllfilterSelected()
            {
                var arrAll = $("#filter_list li");
                arrAll.forEach(function(item){
                    if(item.className == "filter-selected"){
                        $(item).removeClass("filter-selected");}
                });
            }

            // 筛选精华帖
            $("#filter_list li").on("click",function(){
                if(this.className == "filter-selected"){
                    $(this).removeClass("filter-selected");
                    if(this.id == "level_selected")  level = 0;
//                    else if(this.id == "acrossCity_selected")  acrossCity = 0;
                    else if(this.id == "noreply_selected")  noreply = 0;
                    else if(this.id == "noadopt_selected")  noadopt = 0;
                    else if(this.id == "noreply_t_selected")  noreply_t = 0;
                    else if(this.id == "report_selected")  reported = 0;
                }else{
                    //$(this).addClass("filter-selected");
                    if(this.id == "level_selected")  level = 1;
//                    else if(this.id == "acrooCity_selected")  acrossCity = 1;
                    else if(this.id == "noreply_selected")  noreply = 1;
                    else if(this.id == "noadopt_selected")  noadopt = 1;
                    else if(this.id == "report_selected")  {
                        reported = 1;
                        removeAllfilterSelected();
                        $(this).addClass("filter-selected");
                    }
                    if(!reported)
                         $(this).addClass("filter-selected");
                }
            });


            $("#finish").on("click",function(){
                $("#filter_list").css("display","none");
                $("#mask").css("display","none");
                $("#filter").removeClass("selected");
                $(".filter img").attr("src","../../images/arrow_down.png");

                qString = "?level="+level;
//                qString += "&acrossCity="+acrossCity;
                qString += "&noreply="+noreply;
                qString += "&noadopt="+noadopt;
                qString += "&noreply_t="+noreply_t;
                qString += "&reported="+reported;

                $("#post_list").html("");
                var index = c.data.url.indexOf("?");
                if(index > 0){
                    c.data.url = c.data.url.substring(0,index);
                }
                c.data.url += qString;
                netWork(c.data,c.listHandle);
            });
            $("#mask").on("click",function(){
                $("#filter").removeClass("selected");
                $(".filter img").attr("src","../../images/arrow_down.png");
                $("#classify").removeClass("selected");
                $(".classify img").attr("src","../../images/arrow_down.png");
                $("#mask").css("display","none");
                $("#filter_list").css("display","none");
                $("#select_list").css("display","none");
                <!--  宝宝树66小区二次改造    add   gct  20170804   start   -->
                $("#select_Community").css("display","none");
                $(".community img").attr("src","../../images/arrow_down.png");
                $("#community").removeClass("selected");
                <!--  宝宝树66小区二次改造    add   gct  20170804   end   -->
            });

            $(".post-list section .title,.post-list section .content").live("click",function(){


                $("#post_details").html("");
                $("#post_details").html(dHtml);
                if(w.postDet != undefined)delete postDet;
                if(w.postDetails != undefined)delete postDetails;
                methodDetail(w);
                console.log('this.parentNode.dataset.objId');
                console.log(this.parentNode.dataset.objId);
                w.postDet = new postDetails(this.parentNode.dataset.objId,this.parentNode.dataset.category);
                postDet.evt();
                $(".post-details").css("transform","translate3d(0,0,0)");
                $(".post-details").css("-webkit-transform","translate3d(0,0,0)");
                c.lastId = this.parentNode.id;
                //}
            });

            $("#search img").on("click",function(){
/*alert(communityId);*/
                searchPage = 1;
                $("#post_list").html("");
                <!--  宝宝树66小区二次改造    add   gct  20170808   start   -->
                c.data = {"url":"/rest/v1.0/Systems/searchAppUgcNew/0/"+userId+"/1/"+communityId+"/deviceId",method: "post",data: "keyword="+$("#search input").val(),"loading": c.listload,"endLoading": c.removeloading};
                <!--  宝宝树66小区二次改造    add   gct  20170808  end   -->
                netWork(c.data,c.listHandle);
            });
            //显示大图事件
            $(document).on("click",".img-area div",function(){
                var img = [],imgDiv = this.parentNode.childNodes,
                    current = this.style.backgroundImage.replace("url(","").replace(")","");

                for(var i = 0;i < imgDiv.length;i++){
                    var reg = new RegExp('"',"g");
                    str = imgDiv[i].style.backgroundImage.replace("url(","").replace(")","").replace(reg, "").replace("?imageView2/1/w/200/h/200/q/75/format/jpg","").replace("http://t.img.66xiaoqu.com","");
                    img.push(str);
                    if(current == imgDiv[i].style.backgroundImage.replace("url(","").replace(")","")){
                        current = i;
                    }
                }
                var type = params.type;
                if (type == 'android') {
                    try{
                        webviewhandle.showImage(img.toString(), current);//webviewhandle为webview注册对象
                    }catch(exception)
                    {
                        console.log('not android');
                    }
                } else if (type == 'ios') {
                    var vCode = params.vcode;
                    if (vCode != null && parseInt(vCode) > 200033) {
                        document.location.href = "66xiaoqu:showImage##images=" + img + "&nbsp;index=" + current;
                    }
                }
                //过时的接口调用：显示大图
                //imgBoot.Init.call(imgBoot,img,current);
                //imgBoot.art.css("display","block");
            })
        },
        ////切换帖子类型
        //clientCategoryEvent:function()
        //{
        //    var classData = {};
        //    if(buttonControlClass && category != "neighbourActivity" && $("#add_classify_item").text() != "点击选择分类"){
        //        classData = {"url":"/rest/v1.0/backoffice/question/changeQuestionCategory/"+questionId+"/"+classVal};
        //        netWork(classData,c.setClassHandle);
        //    }
        //},
        //ClientexGetTitle:function()
        //{    //获取标题
        //    if(classVal)
        //        return  classVal;
        //    else
        //        return "未分类"
        //},
        dUrl: "",
        lastId: "",//点击进入详情帖子的id
        itemClass: false
    };
    w.post = post;
})(window);
var post = new post();
post.evt();

var methodDetail = function(w){
    var postDetails = function (qId,cry) {
            this.Init(qId,cry);
            return this;
        }, c,
        isShield = true,
        isAcrossCity = true,
        controlScroll = false,alertItem,
        classifyItem = "",
        questionId = "",category = "",
        rpage = 0,reqControl = false,level = 0,acrossCity = 0,
        questionId2 = "",communityId2 = "",category2 = "",
        onlyTop = false,allTop = false,userId = "",
        desc = "",//描述，修改标签需要
        tag = [],//标签数组
        classVal = "",//类别
        sendType = 0,//1 推送、3 删除、2 添加到首页
        openType = 1,//添加到首页用到的类型
        contentCreatedBy = "",//创建者id
        tagName = "",userRole = 1,
        classObj = {"question":"邻里问问","share":"随便说说","essence":"66精选"},//分类对象
        classArray = ["question","share","essence"],
        tagArrayId = [],//标签id数组
        buttonControlTop = false,buttonControlAllTop = false,buttonControlEssence = false,buttonControlLabel = false,buttonControlClass = false;


    postDetails.prototype = {
        Init: function (qId,cry) {
            c = this;
            questionId = qId;
            category = cry;
            //if(sessionStorage.loginData != null && sessionStorage.resUrl != null){
            //    userId = eval( "(" + sessionStorage.loginData + ")").data[0].objId;
            //    //userId = "549968e5bc537bb017000a53";
            //}else{
            //    location.href = "/pages/moderatorManager/html/login.html";//没数据进登录页
            //}

            userId = getQueryString('userId');


            alertItem = new iScroll("alert_list", { "useTransition": true, "vScrollbar": false, "hScroll": false, "onScrollStart": function () {
                controlScroll = true;},
                "onScrollEnd": function () {
                    if(controlScroll){
                        controlScroll = false;
                        var count = Math.round(Math.abs(this.y)/44),y = -count*44;
                        this.scrollTo(0, y, 100);
                        $($("#alert_list li")[count+1]).siblings().removeClass("selected");
                        $($("#alert_list li")[count+1]).addClass("selected");
                        classifyItem = $("#alert_list li")[count+1].innerText;
                        classVal = $("#alert_list li")[count+1].dataset.val;
                    }
                }});

            if(category == "neighbourActivity"){
                $("#add_classify").css("display","none");
                $("#delete").css("display","none");
                $("#add_home").css("width","100%");
                $("footer").css("background","#fff");
                openType = 6;
                tagName = "邻里活动";

                this.data = {"url":"/rest/v1.0/activity/getDetailOfActivity/"+ questionId +"/"+userId+"/opm4mobile"};
                netWork(this.data,this.initData);

                this.rdata = {"url":"/rest/v1.0/activity/getDetailReplyOfActivity/"+ questionId +"/"+rpage+"/"+userId+"/opm4mobile"};
                netWork(this.rdata,this.initReply);
            }else {
                openType = 1;
                tagName = "话题";
                if(category == "share"){
                    //openType = 2;
                    //tagName = "公告";
                }

                this.data = {"url":"/rest/v1.0/Questions/getDetailOfQuestion/"+ questionId +"/"+userId+"/opm4mobile"};
                netWork(this.data,this.initData);

                this.rdata = {"url":"/rest/v1.0/Questions/getDetailReplyOfQuestion/"+ questionId +"/"+rpage+"/"+userId+"/opm4mobile"};
                netWork(this.rdata,this.initReply);
            }

            $("#iscroll")[0].style.height = (document.body.offsetHeight - $("#iscroll")[0].offsetTop - $("footer")[0].offsetHeight)+"px";
            replyList = new iScroll("iscroll", { "useTransition": true, "vScrollbar": false, "hScroll": false, "onScrollStart": function () {
            }, "onScrollEnd": function () {
                if(reqControl && (Math.abs(this.maxScrollY) - Math.abs(this.y) < 100 || this.maxScrollY >= 0)){
                    reqControl = false;

                    c.rdata.url = "/rest/v1.0/Questions/getDetailReplyOfQuestion/"+ questionId +"/"+rpage+"/"+userId+"/opm4mobile";

                    c.rdata.loading = c.listload;
                    c.rdata.endLoading = c.removeloading;
                    netWork(c.rdata,c.initReply);
                }
            }});
        },
        initData: function(data){
            var d = eval( "(" + data + ")"),imagesList = "",
                date = new Date(d.data.dateCreated),lastTime = new Date(d.data.deadline),tag2 = "",initDesc = "";
            initDesc = d.data.desc;//d.data.desc.length > 30?d.data.desc.substring(0,30)+"...":d.data.desc;
            if(d.data.category == "neighbourActivity"){
                initDesc = "【" + d.data.title + "】" + initDesc;
                if(d.data.activityType == 1){
                    initDesc = "<span style = 'color: #F7744A;'>#团购#</span> " + initDesc;
                }
                $("#name_time").css("width","45%;");
                $(".l-time2").css("display","block");
                lastTime = formatTime(lastTime);
                $("#l_time").text(lastTime);
            }
            try{
                console.log(d.data.createdBy.images[0].imageURL);
                /***
                 * 更动原因：存在一个完成的连接，http开头
                 */
                if(d.data.createdBy.images[0].imageURL.indexOf('http:')==0){
                    $("#title_icon")[0].src = d.data.createdBy.images[0].imageURL+headimg;
                }else{
                $("#title_icon")[0].src = sessionStorage.resUrl + d.data.createdBy.images[0].imageURL+headimg;}
            }
            catch (exception) {
                console.log("默认图片不存在");
            }
            //$("#title_icon")[0].src = sessionStorage.resUrl + d.data.createdBy.images[0].imageURL;
            $("#t_name").text(d.data.createdBy.nickName);
            $("#t_time").text(formatTime(date) + " 发布 "+d.data.community.communityName);
            console.log(d.data.community.communityName);
            $("#content").html(initDesc);

            if(d.data.images != null)
            for(var i = 0;i < d.data.images.length;i++){
                imagesList += "<div style = 'background: url("+sessionStorage.resUrl+d.data.images[i].imageURL.concat(thumbnail)+") no-repeat center;background-size: 100% auto'></div>";
            }
            $("#img_area").html(imagesList);
            $("#browse").text(d.data.browserCountStr);
            $("#praise").text((d.data.praiseCount?d.data.praiseCount:0));

            if(d.data.category) $("#add_classify_item").text(classObj[d.data.category]);
            classVal = d.data.category;
            for(var i = 0;i < classArray.length;i++){
                if(classArray[i] == d.data.category){
                    var y = -i*44;
                    alertItem.scrollTo(0,y,100);
                    $($("#alert_list li")[i+1]).siblings().removeClass("selected");
                    $($("#alert_list li")[i+1]).addClass("selected");
                    break;
                }
            }
            if(d.data.tag && d.data.tag.length > 0){
                tagArrayId = d.data.tag;
                d.data.tag.forEach(function(item){
                    tag2 += item.value+" ";
                    tag.push(item.objId);
                });
                $("#add_label_item").text(tag2);
                $("#selected_label").append(tag2);
            }
            //if(d.data.isTop) {$("#only_top img").attr("src","../../images/filter_selected.png"); onlyTop = true;}
            if(d.data.isTop) {
                $('#only_top div').css({color:'#DE5D33'});
                $('#only_top div').text('取消置顶'); onlyTop = true;
                $("#only_top img").attr("src","../../images/top_icon_selected.png");
            }
            //if(d.data.isTopAll) {$("#all_top img").attr("src","../../images/filter_selected.png"); allTop = true;}
            //if(d.data.isPrime) {$("#essence img").attr("src","../../images/filter_selected.png"); level = 1;}
            if(d.data.isPrime) {
                $('#essence div').css({color:'#DE5D33'});
                $("#essence div").text('取消精华');
                {$("#essence img").attr("src","../../images/essence_icon_selected.png"); level = 1;}
            }
            //console.log("isShield is log");
            //console.log(d.data.isShield);
            if(d.data.isShield) {
                $('#shielding div').css({color:'#DE5D33'});
                $("#shielding div").text('取消屏蔽');
                {$("#shielding img").attr("src","../../images/isShield_icon_selected.png"); isShield = false;}
            }

            if(d.data.acrossCity) {
                $('#acrossCity div').css({color:'#DE5D33'});
                $("#acrossCity div").text('取消同城不可见');
                {$("#acrossCity img").attr("src","../../images/acrossCity_selected.jpg"); isAcrossCity = false;}
            }

            replyList.refresh();
            console.log("d.data");
            console.log(d.data);
            questionId2 = d.data.objId;
            communityId2 = d.data.community.objId;
            category2 = d.data.category;
            desc = d.data.desc;
            contentCreatedBy = d.data.createdBy.objId;
            if(d.data.createdBy.userType == "talent")userRole = 2;//达人

            //获取标签
            //netWork({"url":"/rest/v1.0/masterData/regions/getDataDictionaryByCategory/02"},c.getLabel);
            $('#question_detail').text(classObj[d.data.category]);
        },
        delReply:function() {
            console.log(c.Node.dataset);
            var data = c.Node.dataset;
            var sendData = {"url":"/rest/v1.0/mis/question/deleteReply",
                "method":"post","data":
                "contentId="+questionId+"&replyBy="+data.replyby+"&replyId=" + data.replyid};
            netWork(sendData,c.successful);
        },
        initReply: function(data){
            var d = eval( "(" + data + ")"),html = "",date = {};
            $("#comment_title").text(d.data.replyCountStr?d.data.replyCountStr:0);
            $("#replyCount").text((d.data.replyCountStr?d.data.replyCountStr:0));
            if(d.data.replies.length == 0){
                document.getElementById("comment_content").innerHTML += "<li id = 'scroll_tip2' style = 'padding: 12px 0;font-size: 14px; color: #ccc;text-align: center;'>没有更多数据了</li>";
                replyList.refresh();
                replyList.scrollTo(0,replyList.maxScrollY,0);
                $('.am-btn').on("click",function(){
                    $("#mask1").css("display","block");
                    c.Node = event.target;
                    tip.confirm.call(null, {"str":"确定删除: "+ c.Node.parentNode.getElementsByClassName('r-content')[0].textContent+" 回复吗？","data":c.Node.dataset,"method":c.delReply,cancelMethod: function(){
                        $("#mask1").css("display","none");
                    }});
                });
                return;
            }

            for(var count in d.data.replies)
            {
                var item = d.data.replies[count];
                var imagesList="";
                date = new Date(item.dateReplied);
                item.images.forEach(function(item)
                {
                   imagesList += "<div style = 'background: url("+sessionStorage.resUrl+item.imageURL.concat(thumbnail)+") no-repeat center;background-size: 100% auto'></div>";
                });
                html = "<li>"+
                    "<img src = '"+sessionStorage.resUrl + item.repliedBy.images[0].imageURL+headimg+"' onerror = 'imgLoadError(this)'>"+
                    "<span class = 'r-name ell'>"+item.repliedBy.nickName+"</span>"+
                    "<span class = 'r-time'>"+formatTime(date)+"</span>"+
                    "<span class='am-btn am-btn-warning' data-replyBy='"+item.repliedBy.objId+"' data-replyId='"+item.objId+"' >删除</span>"+
                    "<div class = 'clear'></div>"+
                    "<span class = 'r-content'>"+item.replyDesc+"</span>"+
                    "<section><div class = 'img-area'>"+imagesList+"</div></section>"
                    "</li>";
                $("#comment_content").append(html);
            }

            $('.am-btn').on("click",function(){
                $("#mask1").css("display","block");
                c.Node = event.target;
                tip.confirm.call(null, {"str":"确定删除: "+ c.Node.parentNode.getElementsByClassName('r-content')[0].textContent.substr(0, 20) +" 回复吗？","data":c.Node.dataset,"method":c.delReply,cancelMethod: function(){
                    $("#mask1").css("display","none");
                }});
            });
            rpage++;
            reqControl = true;
            replyList.refresh();
        },
        setHandle: function(data){
            var d = eval( "(" + data + ")");
            if(d.result.status == 0){
                buttonControlTop = false
                if('已经存在一个置顶帖子了哦' === d.result.message)
                {
                    $('#only_top div').css({color:'#707274'});
                    $('#only_top div').text('置顶无效');
                    $('#only_top img').attr("src","../../images/top_icon_normal.png");
                }
                tip.toast(d.result.message);
            }
        },
        deletePost: function(d){
            //var d = eval( "(" + data + ")");
            if(d.result.status == "1"){
                //location.href = "/pages/moderatorManager/html/post/post.html";
                post.data.url = post.dUrl;
                netWork(post.data,post.listHandle);
                $("#post_list").html("");
                $(".post-details").css("transform","translate3d(-100%,0,0)");
                $(".post-details").css("-webkit-transform","translate3d(-100%,0,0)");
            }
        },
        getLabel: function(data){
            var d = eval( "(" + data + ")"),i = 0;
            d.data.forEach(function(item){
                $("#label_list span")[i].dataset.labelId = item.objId;
                $("#label_list span")[i].innerText = item.value;

                for(var j = 0;j < tagArrayId.length;j++){
                    if(tagArrayId[j].objId == item.objId){
                        $("#label_list span")[i].className = "selected";
                        break;
                    }

                }
                i++;
            });
        },
        successful:function(data)
        {
            $("#mask1").css("display","none");
            var d = eval( "(" + data + ")");
            if(d.result.status == 1) tip.toast("该操作完成"); //else tip.toast(message);
            c.Node.parentElement.remove()
        },
        shieldinghandle:function(data){
            $("#mask1").css("display","none");
            if(data.result.status == 1) tip.toast("该操作完成"); //else tip.toast(message);
        },
        acrossCityhandle:function(data){
            $("#mask1").css("display","none");
            if(data.result.status == 1) tip.toast("该操作完成"); //else tip.toast(message);
        },
        toHome: function(data){
            var d = eval( "(" + data + ")");
            if(d.result.status == 1) tip.toast("添加首页成功！"); //else tip.toast(message);
        },
        pushHandle: function(data){
            var d = eval( "(" + data + ")");
            if(d.result.status == 1){
                tip.toast("推送成功！");
            }
        },
        listload: function(){
            document.getElementById("comment_content").innerHTML += "<li id = 'scroll_tip2' style = 'padding: 12px 0;font-size: 14px; color: #ccc;text-align: center;'>正在加载中...</li>";
            replyList.refresh();
            replyList.scrollTo(0,replyList.maxScrollY,0);
        },
        removeloading: function(){
            document.getElementById("comment_content").removeChild(document.getElementById("scroll_tip2"));
            replyList.refresh();
        },
        setLabelHandle: function(data){
            var d = eval( "(" + data + ")");
        },
        itemNew: function(data){//更新每项数据
            var d = eval( "(" + data + ")");
            if(d.data.isPrime&&$("#"+post.lastId).find(".jing").length == 0){
                $("#"+post.lastId).find(".title").append("<img src = '/pages/moderatorManager/images/jing.png' class = 'jing'>");
            }else if(!d.data.isPrime&&$("#"+post.lastId).find(".jing").length != 0){
                $("#"+post.lastId).find(".title").find(".jing").remove();
            }

            if(post.itemClass){
                if(d.data.isTop&&$("#"+post.lastId).find(".ding").length == 0){
                    $("#"+post.lastId).find(".title").append("<img src = '/pages/moderatorManager/images/ding.png' class = 'ding'>");
                }else if(!d.data.isTop&&$("#"+post.lastId).find(".ding").length != 0){
                    $("#"+post.lastId).find(".title").find(".ding").remove();
                }
            }else{
                if(d.data.isTopAll&&$("#"+post.lastId).find(".ding").length == 0){
                    $("#"+post.lastId).find(".title").append("<img src = '/pages/moderatorManager/images/ding.png' class = 'ding'>");
                }else if(!d.data.isTopAll&&$("#"+post.lastId).find(".ding").length != 0){
                    $("#"+post.lastId).find(".title").find(".ding").remove();
                }
            }
        },
        evt: function(){
            $("#back_del").on("click",function(){
                //location.href = "/pages/moderatorManager/html/post/post.html";
                //post.data.url = post.dUrl;
                //netWork(post.data,post.listHandle);
                //$("#post_list").html("");
                $("#mask").css("display","none");
                $(".post-details").css("transform","translate3d(-100%,0,0)");
                $(".post-details").css("-webkit-transform","translate3d(-100%,0,0)");
            });
            $("#only_top,#all_top,#essence,#shielding,#acrossCity").on("click",function(){
                if(this.id == "only_top"){
                    //if(buttonControlTop == false){buttonControlTop = true;}else{buttonControlTop = false;}
                  var backOrOperation = function(){
                      if($('#only_top div').text() === '取消置顶'){
                          $('#only_top div').css({color:'#000000'});
                          $('#only_top div').text('置顶');
                          $('#only_top img').attr("src","../../images/top_icon_normal.png")
                          onlyTop = false;
                      }else{
                          $('#only_top img').attr("src","../../images/top_icon_selected.png")
                          $('#only_top div').css({color:'#DE5D33'});
                          $('#only_top div').text('取消置顶');
                          onlyTop = true;
                      }
                  }
                    backOrOperation();
                    isTop();
                }else if(this.id == "all_top"){
                    if(buttonControlAllTop == false){buttonControlAllTop = true;}else{buttonControlAllTop = false;}
                    if($("#all_top img")[0].src.search(/filter_selected/) > 0){
                        $("#all_top img").attr("src","../../images/filter_normal.png");
                        allTop = false;
                    }else{
                        $("#all_top img").attr("src","../../images/filter_selected.png");
                        allTop = true;
                    }
                }else if(this.id == "essence"){
                    //if(buttonControlEssence == false){buttonControlEssence = true;}else{buttonControlEssence = false;}
                    var essenceOperation = function()
                    {
                        if($("#essence div").text() === '取消精华'){
                            $('#essence div').css({color:'#707274'});
                            $("#essence div").text('设精华');
                            $('#essence img').attr("src","../../images/essence_icon_normal.png");
                            level = 0;
                        }else{
                            $('#essence div').css({color:'#DE5D33'});
                            $("#essence div").text('取消精华');
                            $('#essence img').attr("src","../../images/essence_icon_selected.png");
                            level = 1;
                            console.log("是精华");
                        }
                    }
                    essenceOperation();
                    try {
                        isEssence();
                    }catch(exception)
                    {
                        essenceOperation();
                    }
                }else if("shielding" == this.id) {
                    var shieldingOperation = function()
                    {
                        if($("#shielding div").text() === '取消屏蔽'){
                            $('#shielding div').css({color:'#707274'});
                            $("#shielding div").text('设屏蔽');
                            $('#shielding img').attr("src","../../images/isShield_icon_normal.png");
                            level = 0;
                        }else{
                            $('#shielding div').css({color:'#DE5D33'});
                            $("#shielding div").text('取消屏蔽');
                            $('#shielding img').attr("src","../../images/isShield_icon_selected.png");
                            level = 1;
                            console.log("已屏蔽");
                        }
                    }
                    shieldingOperation();
                    try {
                        isShielding();
                    }catch(exception)
                    {
                        shieldingOperation();
                    }
                } else if("acrossCity" == this.id) {
                    var acrossCityOperation = function()
                    {
                        if($("#acrossCity div").text() === '取消同城不可见'){
                            $('#acrossCity div').css({color:'#707274'});
                            $("#acrossCity div").text('同城不可见');
                            $('#acrossCity img').attr("src","../../images/acrossCity_normal.jpg");
                            isAcrossCity = 0;
                        }else{
                            $('#acrossCity div').css({color:'#DE5D33'});
                            $("#acrossCity div").text('取消同城不可见');
                            $('#acrossCity img').attr("src","../../images/acrossCity_selected.jpg");
                            isAcrossCity = 1;
                        }
                    }
                    acrossCityOperation();
                    try {
                        doAcrossCity();
                    }catch(exception)
                    {
                        acrossCityOperation();  // 恢复
                    }
                }

            });
            var checkDesc = function(data,length)
            {
                 if(data.length===0) {
                     tip.toast('请输入描述');
                     throw new Error('请输入描述');
                 }else if(data.length<length) {
                     tip.toast('请输入至少'+length+'个字');
                     throw new Error('请输入至少'+length+'个字');
                 }
            }
            //取消
            $("#push_cancel").on("click",function(){
                $("#content_push").css("display","none");
                $("#mask1").css("display","none");
            });
            console.log("questionId");
            console.log(questionId);
            //推送、删除、添加、屏蔽到首页
            $("#push_confirm").on("click",function(){
                var sendData = {},delDesc = $("#alert_content_textarea").val();
                $("#content_push").css("display","none");
                $("#mask1").css("display","none");

                if(sendType == 1){
                    try {
                        checkDesc(delDesc,4);
                    }catch (exception)
                    {
                        return;
                    }
                    sendData = {"url":"/rest/v1.0/backoffice/Systems/confirmPushByModerator","method":"post","data": "contentId="+questionId+"&communityId="+communityId2+"&tag="+tagName+"&content="+desc+"&type="+1+"&openType="+openType+"&createdBy="+contentCreatedBy+"&desc="+delDesc+"&userId=" + userId};
                    netWork(sendData,c.pushHandle);
                }else if(sendType == 2){
                    var formData = new FormData();
                    formData.append("message", delDesc);
                    formData.append("community", communityId2);
                    formData.append("openType", openType);
                    formData.append("contentId", questionId);
                    formData.append("contentCreatedBy", contentCreatedBy);
                    formData.append("type", 2);
                    if(category == "neighbourActivity") formData.append("tag", "活动"); else formData.append("tag", "话题");


                    sendData = {"url":"/rest/v1.0/backoffice/banner/addCommunityBanner","method":"post","formData": formData};
                    netWork(sendData,c.toHome);
                }else if(sendType == 3){
                    try {
                        checkDesc(delDesc,2);
                    }catch (exception)
                    {
                        return;
                    }
                    var questionTemp = questionId;
                    console.log("what happen questionId");
                    console.log(questionTemp);
                    var delOperation = function(questionId){
                        var sendData =
                        {"url":"/rest/v1.0/Questions/deleteQuestionByModerator",
                            "method":"post","native":false,
                            "data": {questionId:questionId,delDesc:delDesc,
                                userId:contentCreatedBy,userRole:userRole}
                        };//"questionId="+questionId+"&delDesc="+delDesc+"&userId="+userId+"&userRole="+userRole
                        console.log(sendData);
                        //console.log(d.data.objId);
                        netWork(sendData,c.deletePost);
                        $("#mask1").css("display","none");
                    }
                    var delTemp = delOperation.call(null,questionId);
                    $("#mask1").css("display","block");
                    //tip.confirm({"str":"确定删除吗？","method":delTemp,cancelMethod: function(){
                    //    $("#mask1").css("display","none");
                    //}});
                }
            });

            $("#open_push,#add_home,#delete").on("click",function(){
                if(this.id == "open_push"){
                    $("#alert_content_title")[0].innerText = "推送内容";
                    $("#alert_content_textarea").attr("placeholder","输入一个吸引邻居的推送消息吧");
                    $("#push_confirm").text("推送");
                    sendType = 1;
                }else if(this.id == "add_home"){
                    $("#alert_content_title").text("添加到首页");
                    $("#alert_content_textarea").attr("placeholder","请输入一个吸引邻居的标题吧");
                    $("#push_confirm").text("添加");
                    sendType = 2;
                }else if(this.id == "delete"){
                    $("#alert_content_title").text("删除内容");
                    $("#alert_content_textarea").attr("placeholder","请输入删除的原因");
                    $("#push_confirm").text("删除");
                    sendType = 3;
                }
                $("#content_push").css("display","block");
                $("#mask1").css("display","block");
            });

            //$("#add_label").on("click",function(){
            //    $("#label_select").css("transform","translate3d(0,0,0)");
            //    $("#label_select").css("-webkit-transform","translate3d(0,0,0)");
            //    buttonControlLabel = true;
            //});
            $("#back2").on("click",function(){
                $("#label_select").css("transform","translate3d(-100%,0,0)");
                $("#label_select").css("-webkit-transform","translate3d(-100%,0,0)");
                if($("#selected_label").text() == ""){
                    $("#add_label_item").text("点击添加标签");
                    $("#add_label_item").css("color","#776C6A");
                }else{
                    $("#add_label_item").text($("#selected_label").text());
                    $("#add_label_item").css("color","#000");
                    //tag = $("#selected_label").text().replace(/(\s*$)/g,"").split(" ");//去右边空格
                }
            });
            //$("#label_select")[0].addEventListener("touchmove",function(e){
            //    e.stopPropagation();
            //},false);
            $("#label_list span").on("click",function(){
                var content = this.innerText;
                if(this.className == "selected"){
                    $(this).removeClass("selected");
                    $("#selected_label").text($("#selected_label").text().replace(content+" ",""));
                    for(var i = 0;i< tag.length; i++){
                        if(tag[i] == this.dataset.labelId){
                            tag.splice(i,1);
                            break;
                        }
                    }
                }else{
                    $(this).addClass("selected");
                    $("#selected_label").append(content+" ");
                    tag.push(this.dataset.labelId);
                }
            });

            $("#add_classify").on("click",function(){
                $("#alist").css("display","block");
                $("#mask1").css("display","block");
                alertItem.refresh();
                buttonControlClass = true;
            });

            $("#cancel-item,#confirm-item").on("click",function(){
                $("#alist").css("display","none");
                $("#mask1").css("display","none");

                if(this.id == "confirm-item"){
                    exChangeCategory();
                    $("#add_classify_item").text(classifyItem);
                    $('#question_detail').text(classifyItem);
                    $("#add_classify_item2").css("display","none");

                }
            });
            //网络请求部分
            var reInit = function()
            {
                setTimeout(function(){
                    if(buttonControlTop || buttonControlEssence || buttonControlAllTop || buttonControlLabel || buttonControlClass){
                        tip.toast("设置完成!");
                    }
                },500);

                c.data = {"url":"/rest/v1.0/Questions/getDetailOfQuestion/"+ questionId +"/"+userId+"/opm4mobile"};
                netWork(c.data,c.itemNew);
            };

            //设置 是否为精华
            var isEssence = function(callback)
            {
                var levelData = {};var rDesc = "您的话题被设为精华";
                if(userRole == 2)rDesc = "您的话题被设为精华";//达人
                if(level == 1){
                    levelData = {"url":"/rest/v1.0/backoffice/question/changeQuestionLevel","method":"post","data": "questionId="+questionId2+"&level="+level+"&userRole="+userRole+"&userId="+contentCreatedBy+"&openType=1"+"&desc="+rDesc+"&tag=话题"+"&setUserId=" + userId,"sync":"false"};
                    console.log("level 1"+levelData);
                }else{
                    /*  宝宝树66小区二次改造    mod   guo.xiaomin  20170825  start   */
                    // 置顶，精华，屏蔽
                    // levelData = {"url":"/rest/v1.0/backoffice/question/changeQuestionLevel","method":"post","data": "questionId="+questionId2+"&level="+level+"&userRole="+userRole+"&userId="+contentCreatedBy,"sync":"false"}; // 旧
                    levelData = {"url":"/rest/v1.0/backoffice/question/changeQuestionLevel","method":"post","data": "questionId="+questionId2+"&level="+level+"&userRole="+userRole+"&userId="+contentCreatedBy+"&setUserId=" + userId,"sync":"false"}; // 新
                    /*  宝宝树66小区二次改造    mod   guo.xiaomin  20170825  end   */
                    console.log("level 0"+levelData);
                }
                try {
                    netWork(levelData, c.setHandle);

                    /*  宝宝树66小区二次改造    add   guo.xiaomin  20170804   start   */
                    // if(onlyTop) {
                    //
                    //     var eventId = "success_move_essence"; // 安卓用
                    //     if (params.type === "ios") {
                    //         eventId = "successfulMoveEssence";    // IOS用
                    //     }
                    //
                    //     MobclickAgent.onEvent(eventId); // 成功置顶帖子
                    // }
                    /*  宝宝树66小区二次改造    add   guo.xiaomin  20170804   end   */

                }catch (exception)
                {
                    console.log('isEssence is back now');
                }
                 reInit();
            }
            //设置是否屏蔽
            var isShielding = function()
            {
                var shieldOperation = function(questionId){
                    var sendData =
                    {"url":"/rest/v1.0/mis/question/shield",
                        "method":"post","native":false,
                        "data": {questionId:questionId,
                            /*  宝宝树66小区二次改造    add   guo.xiaomin  20170825  start   */
                            // 置顶，精华，屏蔽
                            userId:userId, // 小区大使ID,contentCreatedBy:帖子创建人ID
                            /*  宝宝树66小区二次改造    add   guo.xiaomin  20170825  end   */
                            isShow :   isShield // 屏蔽为true
                        }
                    };
                    isShield = !isShield;
                    console.log(sendData);
                    netWork(sendData,c.shieldinghandle);
                }
                shieldOperation.call(null,questionId);
            }

            //设置同城不可见
            var doAcrossCity = function()
            {
                var acrossCityOperation = function(questionId){
                    var sendData =
                    {"url":"/rest/v1.0/mis/question/acrossCity",
                        "method":"post","native":false,
                        "data": {questionId:questionId,
                            acrossCity :   isAcrossCity // 同城不可见为true
                        }
                    };
                    isAcrossCity = !isAcrossCity;
                    netWork(sendData,c.acrossCityhandle);
                }
                acrossCityOperation.call(null,questionId);
            }

            //设置是否为置顶
            var isTop = function()
            {
                var topData = {};
                if(onlyTop){
                    //buttonControlTop = true;
                    topData = {"url":"/rest/v1.0/backoffice/question/moveQuestionToTop","method":"post","data": "questionId="+questionId2+"&communityId="+communityId2+"&category="+category2+"&userId=" + userId,"sync":"false"};
                }else{
                    /*  宝宝树66小区二次改造    mod   guo.xiaomin  20170825  start   */
                    // 置顶，精华，屏蔽
                    // topData = {"url":"/rest/v1.0/backoffice/question/cancelTopQuestion","method":"post","data": "questionId="+questionId2+"&category="+category2,"sync":"false"}; // 旧
                    topData = {"url":"/rest/v1.0/backoffice/question/cancelTopQuestion","method":"post","data": "questionId="+questionId2+"&category="+category2+"&userId=" + userId,"sync":"false"}; // 新
                    /*  宝宝树66小区二次改造    mod   guo.xiaomin  20170825  end   */
                }
                netWork(topData,c.setHandle);
                /*  宝宝树66小区二次改造    add   guo.xiaomin  20170804   start   */
                // if(onlyTop) {
                //
                //     var eventId = "success_move_question_top"; // 安卓用
                //     if (params.type === "ios") {
                //         eventId = "successfulMoveQuestionTop";    // IOS用
                //     }
                //
                //     MobclickAgent.onEvent(eventId); // 成功置顶帖子
                // }
                /*  宝宝树66小区二次改造    add   guo.xiaomin  20170804   end   */
                reInit();
            };

            //修改选择分类
            var exChangeCategory= function()
            {
                var classData = {};
                if(buttonControlClass && category != "neighbourActivity" && $("#add_classify_item").text() != "点击选择分类"){
                    classData = {"url":"/rest/v1.0/backoffice/question/changeQuestionCategory/"+questionId+"/"+classVal};
                    try{
                        netWork(classData,c.setClassHandle);
                    }catch(exception)
                    {
                        console.log('操作失败');
                    }

                }
                //reInit();
            }

            /***
             * 设置完成
             * 废去原因:功能被拆分，去掉状态，无保存按钮来触发了
             */
            $("#selected_over").on("click",function(){
                var topData = {},allData = {},levelData = {},labelData = {},classData = {},rDesc = "";
                //问题置顶
                if(onlyTop){
                    //buttonControlTop = true;
                    topData = {"url":"/rest/v1.0/backoffice/question/moveQuestionToTop","method":"post","data": "questionId="+questionId2+"&communityId="+communityId2+"&category="+category2+"&userId=" + userId,"sync":"false"};
                }else{
                    /*  宝宝树66小区二次改造    mod   guo.xiaomin  20170825  start   */
                    // 置顶，精华，屏蔽
                    // topData = {"url":"/rest/v1.0/backoffice/question/cancelTopQuestion","method":"post","data": "questionId="+questionId2+"&category="+category2,"sync":"false"}; // 旧
                    topData = {"url":"/rest/v1.0/backoffice/question/cancelTopQuestion","method":"post","data": "questionId="+questionId2+"&category="+category2+"&userId=" + userId,"sync":"false"}; // 新
                    /*  宝宝树66小区二次改造    mod   guo.xiaomin  20170825  end   */
                }
                if(buttonControlTop) netWork(topData,c.setHandle);

                //精华帖
                rDesc = "您的话题被设为精华";
                if(userRole == 2)rDesc = "您的话题被设为精华";//达人
                if(level == 1){
                    levelData = {"url":"/rest/v1.0/backoffice/question/changeQuestionLevel","method":"post","data": "questionId="+questionId2+"&level="+level+"&userRole="+userRole+"&userId="+contentCreatedBy+"&openType=1"+"&desc="+rDesc+"&tag=话题"+"&setUserId=" + userId,"sync":"false"};
                }else{
                    levelData = {"url":"/rest/v1.0/backoffice/question/changeQuestionLevel","method":"post","data": "questionId="+questionId2+"&level="+level+"&userRole="+userRole+"&userId="+contentCreatedBy,"sync":"false"};
                }
                if(buttonControlEssence) netWork(levelData,c.setHandle);


                //全部置顶
                //if(allTop){
                //    allData = {"url":"/rest/v1.0/backoffice/activity/moveAllToTop","method":"post","data": "id="+questionId2+"&community="+communityId2,"sync":"false"};
                //}else{
                //    allData = {"url":"/rest/v1.0/backoffice/activity/cancelTopAll","method":"post","data": "id="+questionId2,"sync":"false"};
                //}
                //if(buttonControlAllTop) netWork(allData,c.setHandle);

                //修改问题标签
                //if(buttonControlLabel && tag.length > 0){
                //    if(category != "neighbourActivity"){
                //        labelData = {"url":"/rest/v1.0/backoffice/admin/backOfficeUpdateQuestionByModerator/"+questionId,"method":"post","data": "desc="+desc+"&tag="+JSON.stringify(tag).replace(/[\[\]\"\"]/g,""),"sync":"false"};
                //    }else{
                //        labelData = {"url":"/rest/v1.0/backoffice/activity/backOfficeUpdateActivityServiceByModerator/","method":"post","data": "objId="+questionId+"&tag="+JSON.stringify(tag).replace(/[\[\]\"\"]/g,""),"sync":"false"};
                //    }
                //    netWork(labelData,c.setLabelHandle);
                //}

                //修改选择分类
                if(buttonControlClass && category != "neighbourActivity" && $("#add_classify_item").text() != "点击选择分类"){
                    classData = {"url":"/rest/v1.0/backoffice/question/changeQuestionCategory/"+questionId+"/"+classVal};
                    netWork(classData,c.setClassHandle);
                }

                setTimeout(function(){
                    if(buttonControlTop || buttonControlEssence || buttonControlAllTop || buttonControlLabel || buttonControlClass){
                        tip.toast("设置完成!");
                        buttonControlTop = false;buttonControlEssence = false;buttonControlAllTop = false;buttonControlLabel = false;buttonControlClass = false;
                    }
                },500);

                c.data = {"url":"/rest/v1.0/Questions/getDetailOfQuestion/"+ questionId +"/"+userId+"/opm4mobile"};
                netWork(c.data,c.itemNew);
            });


        }

    };
    w.postDetails = postDetails;
};
//图片放大
//var imgSlide = new slide();
